package com.flying.invest.strategy.model;

import java.util.Date;

import com.flying.framework.annotation.ConstantEnum;
import com.flying.framework.annotation.Param;
import com.flying.framework.data.Data;
import com.flying.framework.data.DataSerializable;
import com.flying.framework.metadata.Meta;

@SuppressWarnings("serial")
@Meta(id="i_strategy_auto_plan",title="定投", table="i_strategy_auto_plan", primaryKeys={"strategy_id"})
public class StrategyAutoPlan extends Data implements DataSerializable {
	public final static String ENTITY_NAME = "i_strategy_auto_plan";
	
	public final static String STRATEGY_ID = "strategy_id";
	public final static String PLAN_START = "plan_start";
	public final static String PLAN_INTERVAL = "plan_interval";
	public final static String PLAN_UNIT = "plan_unit";
	public final static String PLAN_END = "plan_end";
	public final static String TOTAL_NUM = "total_num";
	public final static String AMOUNT = "amount";
	public final static String QUANTITY = "quantity";
	public final static String COMMISSION_TYPE = "commission_type";

	public enum CommissionType implements ConstantEnum<Integer> {
		AMOUNT(0, "金额"), QUANTITY(1, "数量");

		public final int value;
		public final String remarks;

		CommissionType(int value, String remarks) {
			this.value = value;
			this.remarks = remarks;
		}
		
		@Override
		public Integer value() {
			return this.value;
		}

		@Override
		public String text() {
			return remarks;
		}
	}

	public enum UnitType implements ConstantEnum<Integer> {
		DAY(0, "自然日"), WORK_DAY(1, "工作日"), 
		WEEK(2, "周"), DOUBLE_WEEK(3, "双周"), 
		MONTH(4, "月"), SEASON(5, "季"), YEAR(6, "年");

		public final int value;
		public final String remarks;

		UnitType(int value, String remarks) {
			this.value = value;
			this.remarks = remarks;
		}
		
		@Override
		public Integer value() {
			return this.value;
		}

		@Override
		public String text() {
			return remarks;
		}
		
		public static UnitType member(Integer i) {
			Object[] arr = UnitType.class.getEnumConstants();
			for(Object o: arr) {
				@SuppressWarnings("rawtypes")
				ConstantEnum a = (ConstantEnum)o;
				if(a.value().equals(i)) {
					return (UnitType)a;
				}
			}
			return null;
		}
	}
	
	@Param(value=STRATEGY_ID,   required=true,   maxlength=0,	desc="策略ID")
	private Long strategyId;
	
	@Param(value=PLAN_START,   required=true,   maxlength=0,	desc="计划开始" )
	private Date planStart;
	
	@Param(value=PLAN_INTERVAL,   required=true,   maxlength=0,	desc="计划间隔" )
	private Integer planInterval;
	
	@Param(value=PLAN_UNIT,   required=true,   maxlength=0,	desc="间隔单位" )
	private Integer planUnit;
	
	@Param(value=PLAN_END,   required=false,   maxlength=0,	desc="计划结束" )
	private Date planEnd;
	
	@Param(value=TOTAL_NUM,   required=false,   maxlength=0,	desc="投入期数" )
	private Integer totalNum;
	
	@Param(value=AMOUNT,   required=false,   maxlength=0,	desc="买入金额" )
	private Double amount;
	
	@Param(value=QUANTITY,   required=false,   maxlength=0,	desc="买入数量" )
	private Double quantity;
	
	@Param(value=COMMISSION_TYPE,   required=true,   maxlength=0,	desc="委托类型", enumClass=CommissionType.class )
	private Integer commissionType;
	
	
	public Long getStrategyId() {
		return this.strategyId;
	}
	
	public void setStrategyId(Long strategyId) {
		this.strategyId = strategyId;
	}
	
	public Date getPlanStart() {
		return this.planStart;
	}
	
	public void setPlanStart(Date planStart) {
		this.planStart = planStart;
	}
	
	public Integer getPlanInterval() {
		return this.planInterval;
	}
	
	public void setPlanInterval(Integer planInterval) {
		this.planInterval = planInterval;
	}
	
	public Integer getPlanUnit() {
		return this.planUnit;
	}
	
	public void setPlanUnit(Integer planUnit) {
		this.planUnit = planUnit;
	}
	
	public Date getPlanEnd() {
		return this.planEnd;
	}
	
	public void setPlanEnd(Date planEnd) {
		this.planEnd = planEnd;
	}
	
	public Integer getTotalNum() {
		return this.totalNum;
	}
	
	public void setTotalNum(Integer totalNum) {
		this.totalNum = totalNum;
	}
	
	public Double getAmount() {
		return this.amount;
	}
	
	public void setAmount(Double amount) {
		this.amount = amount;
	}
	
	public Double getQuantity() {
		return this.quantity;
	}
	
	public void setQuantity(Double quantity) {
		this.quantity = quantity;
	}

	public Integer getCommissionType() {
		return commissionType;
	}

	public void setCommissionType(Integer commissionType) {
		this.commissionType = commissionType;
	}
	

}